﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace com.core.database
{
    public abstract class DataBusiness
    {
        public delegate IDataAgent CreateDataAgentHandler();
        static string _connectionString = null;
        public static string ConnectionString
        {
            get
            {
                if (_connectionString == null)
                {
                    _connectionString = ConfigurationManager.ConnectionStrings["DX_CONN"].ConnectionString;
                }
                return _connectionString;
            }
        }
        public static event CreateDataAgentHandler CreateDataAgent;
        protected IDataAgent Agent
        {
            get;
            private set;
        }
        public DataBusiness()
        {
            if (CreateDataAgent != null)
            {
                Agent = CreateDataAgent();
            }
            else
            {
                Agent = new SqlProvider(ConnectionString);
            }
        }

    }
}
